import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Upgrades here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Upgrade extends Actor
{
    int wert;
    int typ;
     World w1= null;
    public void act()
    {
        w1= getWorld();
        if(getOneIntersectingObject(Held.class)!=null)
        {
        upgraden(typ,wert,getOneIntersectingObject(Held.class));
        w1.removeObject(this);
    }
    }
    public Upgrade(int ty,int we)
    {
        wert = we;
        typ = ty;
        w1= getWorld();
        img();
    }
    public void img()
    {
                if(typ == 0)
        {
            setImage("upgrade.png");
        }
        else if(typ == 1)
        {
            setImage("upgrade.png");
        }
        else if(typ == 2)
        {
            setImage("upgrade.png");
        }
        else if(typ == 3)
        {
           setImage("upgrade.png");
        }
        else if(typ == 4)
        {
            setImage("upgrade.png");
        }
    }
    public void upgraden(int t, int w, Actor b)
    {
            Held h = (Held) b;
            if(t==0)//life
            {
                h.Leben = h.Leben+w;
            }
            else if(t==1)//geschw
            {
                h.Geschwindigkeit = h.Geschwindigkeit -w;
            }
            else if(t==2)//sprung
            {
                h.Sprunghöhe = h.Sprunghöhe + w;
            }
            else if(t==3)//atk
            {
                h.ATK = h.ATK + w;
            }
            else if(t==4)//def
            {
                h.DEF = h.DEF +w;
            }
        }
    
}
